<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="webroot" value="${pageContext.request.contextPath}" />
<script type="text/javascript" src="${webroot}/static/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="${webroot}/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${webroot}/static/js/bootstrap-table.js"></script>
<script type="text/javascript" src="${webroot}/static/js/app-common-2.00.0.js"></script>
<script type="text/javascript" src="${webroot}/static/js/layer/layer.js"></script>
<script src="${webroot}/static/js/jquery.form.js" type="text/javascript" ></script>
<script type="text/javascript" src="${webroot}/static/js/dcalendar.picker.js"></script>
<link rel="stylesheet" type="text/css" href="${webroot}/static/css/dcalendar.picker.css" />
<link rel="stylesheet" type="text/css" href="${webroot}/static/js/layer/skin/layer.css"/>
<link rel="stylesheet" type="text/css" href="${webroot}/static/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="${webroot}/static/css/bootstrap-table.min.css" />
<link rel="stylesheet" type="text/css" href="${webroot}/static/css/forms.css" />
<html>
<head>
<style type="text/css">
.table>tbody>tr>td, .table>tfoot>tr>td {
    text-align: center;
    vertical-align: middle;
}
</style>
</head>
<body>
	<div>
		<form class="order-form" id="filterForm">
			<div class="control-group clearfix" style="width: 12%;">
				<label>姓名:</label>
				<div class="control">
					<input type="text" class="control-input" id="userName" name="userName" >
				</div>
			</div>
			<div class="control-group clearfix" style="width: 12%;">
				<label>帐号:</label>
				<div class="control">
					<input type="text" class="control-input" id="userId" name="userId" >
				</div>
			</div>
			<div class="control-group clearfix" style="width: 12%;">
				<label>IP:</label>
				<div class="control">
				    <input type="text" class="control-input" id="ip" name="ip" >
				</div>
			</div>
			<div class="control-group clearfix" >
				<label>时间:</label>
				<div class="control">
					<input type="text" class="control-input" id="startTime" name="startTime">-
					<input type="text" class="control-input" id="endTime" name="endTime">
				</div>
			</div>
		 	<div class="control-group clearfix">
				<div class="control">
				   <input type="button" value="查询" id="btn_query" class="layui-btn layui-btn-sm layui-btn-normal"/>&nbsp;
			       <input type="button" value="重置" id="btn_reunion" class="layui-btn layui-btn-sm layui-btn-danger"/>
				</div>
			</div>
		</form>
		<div style="position: relative;top: -11px;">
		    <input type="button" value="导出Excel" id="adbut" class="layui-btn" onclick="doExportCommand();" />
		</div>
		<form id='dictGridDiv'></form>
	</div>
</body>
<script type="text/javascript">
	$('#startTime').dcalendarpicker({
	    format:'yyyy-mm-dd'
	}); 
	
	$('#endTime').dcalendarpicker({
	    format:'yyyy-mm-dd'
	}); 
	$(function() {
		//1.初始化Table
		var oTable = new TableInit();
		oTable.Init();
		$("#btn_query").click(function() {
			$("#dictGridDiv").bootstrapTable('destroy');
			var oTable = new TableInit();
			oTable.Init();
		});
		$("#btn_reunion").click(function() {
			$("#userId").val("");
			$("#userName").val("");
			$("#startTime").val("");
			$("#endTime").val("");
			$("#ip").val("");
			$("#dictGridDiv").bootstrapTable('destroy');
			var oTable = new TableInit();
			oTable.Init();
		});
	});
	var TableInit = function() {
		var oTableInit = new Object();
		//初始化Table
		oTableInit.Init = function() {
			$('#dictGridDiv').bootstrapTable({
					url : '${webroot}/operationlog/querypage',
					dataType : "json",
					toolbar : '#toolbar', //工具按钮用哪个容器
					striped : true, //是否显示行间隔色
					singleSelect : false,
					pagination : true, //分页
					pageNumber : 1, //初始化加载第一页，默认第一页
					queryParams : queryParams,
					pageSize : 10, //每页的记录行数（*）
					pageList : false, //可供选择的每页的行数（*）
					//search: true, //显示搜索框
					sidePagination : "server", //服务端处理分页
					columns : [ 
					           {
								 field : 'id',
								 title : '编号',
								 align : 'center',
								 width : '250'
								 
								},{
								 field : 'createTime',
								 title : '时间',
								 align : 'center',
								 width : '350',
								 formatter : function(val, rowdata,	rowindex, td, trL) {
									if (val == "" || val == null)
										return "";
									return app.inputDate.myformatterTime(new Date(val));
								 }
							    },{
								 field : 'userName',
							     title : '姓名',
								 align : 'center',
								 width : '300'
								},{
								 field : 'userId',
								 title : '帐号',
								 align : 'center',
								 width : '250'
								},{
								 field : 'ip',
								 title : 'IP',
								 align : 'center',
								 width : '250'
							    },{
							     field : 'content',
								 title : '操作内容',
								 align : 'center',
								 width : '500'
								} ]
							});
		};
		function queryParams(params) {
			return {
				pageSize : params.limit, //页面大小
				pageNumber : params.offset, //页码
				userId: $("#userId").val(),
				userName:$("#userName").val(),
				startTime:$("#startTime").val(),
				endTime:$("#endTime").val(),
				ip:$("#ip").val(),
			};
		}
		return oTableInit;
	};
	
	//启用 - 停用
	function Upstatus(userId,userName,status){
		var titie='';
		if(status == 0){
			titie ='确定要启用吗?';
		}else if(status == 1){
			titie ='确定要停用吗?';
		}
		layer.confirm(titie, function() {
			//调用ajax局部启动
			$.ajax({
				url : "${webroot}/sysuser/updatestatus",
				type : "POST",
				data : {
					"userId" : userId,
					"status" : status,
					"userName" : userName
				},
				dataType : "json",
				async : false,
				cache : false,
				success : function(obj) {
					if (obj != null) {
						if (obj.success) {
							layer.msg("操作成功");
						} else {
							layer.msg("操作失败");
						}
					}
				}
			});
			$("#dictGridDiv").bootstrapTable('destroy');
			var oTable = new TableInit();
			oTable.Init();
		});
	}
	
	//新增 - 修改
	function Add(userId){
		window.location.href = '${webroot}/sysuser/detail?id='+userId+"&resourceId=${id}";
	}
	
	//删除
    function Delete(userId,userName){
    		layer.confirm('确定要删除吗?', function() {
    			//调用ajax局部启动
    			$.ajax({
    				url : "${webroot}/sysuser/delete",
    				type : "POST",
    				data : {
    					"id" : userId,
    					"userName" : userName
    				},
    				dataType : "json",
    				async : false,
    				cache : false,
    				success : function(obj) {
    					if (obj != null) {
    						if (obj.success) {
    							layer.msg("删除成功");
    						} else {
    							layer.msg("删除失败");
    						}
    					}
    				}
    			});
    			$("#dictGridDiv").bootstrapTable('destroy');
    			var oTable = new TableInit();
    			oTable.Init();
    		});
	}	 
	
	//export 导出
	function doExportCommand() {
		layer.confirm('确定要导出列表吗?', function(o) {
			var action ="${webroot}/operationlog/export";
			document.getElementById("filterForm").action = action;
			document.getElementById("filterForm").submit();
			layer.close(o);
		});
	}
</script>
</html>